package com.example.pattern.proxy;

import org.springframework.cglib.proxy.InvocationHandler;

import java.lang.reflect.Method;

/**
 * FM_南风
 *
 * @author fengmingming
 * @date 2024/6/25 13:37
 */
public class ProxyInvocationHandler implements InvocationHandler {
    private Object realSubject;

    public ProxyInvocationHandler(Object realSubject) {
        this.realSubject = realSubject;
    }

    @Override
    public Object invoke(Object o, Method method, Object[] objects) throws Throwable {
        System.out.println("动态代理类: 前置处理");
        Object result = method.invoke(realSubject, objects);
        System.out.println("动态代理类: 后置处理");
        return result;
    }
}
